<?php
require 'common.php';
require 'mysql.php';
 


//db //$dbhost, $dbport, $dbuser, $dbpw, $dbname

$game_db = new DBPDO($db_config);


$start_time = strtotime("-1 day 0:0:0");
$end_time = $start_time + 86400;

$time_arr = array();
$time_arr[] = array('start_time' => $end_time,'end_time' => time(),'field' => 'score_now');

$time_arr[] = array('start_time' => 0,'end_time' => $end_time,'field' => 'score_day7');
$time_arr[] = array('start_time' => $start_time,'end_time' => $end_time,'field' => 'score_day1');

foreach ($time_arr as $v){ 
	if( $v['end_time'] + 306 > time() ){
		$sql = 'UPDATE club_user a,(select club_id,uid,sum(score) as score_all from club_room_log_user where time >= '.$v['start_time'].' and time <= '.$v['end_time'].' group by club_id,uid) as b SET a.'.$v['field'].' = b.score_all   WHERE a.club_id = b.club_id and a.uid=b.uid';
		// echo $sql;
		$info = $game_db->update($sql); 
	}
} 


 








